{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Polyglot Magics\n",
    "\n",
    "The BeakerX kernels have magics to run other kernels, including `%%python`.  There are magics for each BeakerX langage: `%%groovy`, `%%java`, `%%scala`, `%%sql`, `%%clojure`, and `%%kotlin`.  There is also a `%%kernel` magic to access any kernel available to Jupyter.  Widgets work through these magics.  These magics give access to Python from the JVM.\n",
    "\n",
    "There are also [Groovy Magics](../python/KernelMagics.ipynb) magics for accessing the JVM from Python.\n",
    "\n",
    "You can communicate between languages with [Autotranslation](GeneralAutotranslation.ipynb).\n",
    "\n",
    "\n",
    "\n",
    "## Python Magic\n",
    "\n",
    "For example, even though this is a Groovy notebook, you can run Python code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "print(\"regular\")\n",
    "{\"output\": \"works\"}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Widgets Work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "import ipywidgets as widgets\n",
    "w = widgets.IntSlider()\n",
    "w"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "w.value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Scala Table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%scala\n",
    "new TableDisplay(Seq(Map(\"a\" -> 1, \"b\" -> 2, \"c\" -> 3),\n",
    "                     Map(\"a\" -> 4, \"b\" -> 5, \"c\" -> 6),\n",
    "                     Map(\"a\" -> 7, \"b\" -> 8, \"c\" -> 8)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Kernel Magic\n",
    "\n",
    "Access any kernel available to Jupyter by name:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%kernel ir\n",
    "x <- rnorm(1000)\n",
    "plot(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%kernel julia-0.6\n",
    "(1 + 1im) * (1 - 1im)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Groovy",
   "language": "groovy",
   "name": "groovy"
  },
  "language_info": {
   "codemirror_mode": "groovy",
   "file_extension": ".groovy",
   "mimetype": "",
   "name": "Groovy",
   "nbconverter_exporter": "",
   "version": "2.4.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": false,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
